//
//  EFLogoutViewCell.m
//  EnjogFood
//
//  Created by guocheng on 2017/6/5.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFLogoutViewCell.h"



@interface EFLogoutViewCell()

@property(strong,nonatomic)UIButton* logoutBtn;

@end


@implementation EFLogoutViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}


-(void)initView{
    [self.contentView setBackgroundColor:[UIColor whiteColor]];
    [self.contentView addSubview:self.logoutBtn];
}



-(void)onClickLogout{
    APP_CONTEXT.accountManager.accountInfo.token = @"";
    APP_CONTEXT.accountManager.accountInfo.userId = @"";
    [APP_CONTEXT.accountManager persistenceAccountInfo];
    if(self.logoutblock){
        self.logoutblock();
    }
}



-(UIButton *)logoutBtn{
    if(_logoutBtn == NULL){
        _logoutBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 40, 35)];
        _logoutBtn.top = 35;
        _logoutBtn.left = 20;
        _logoutBtn.backgroundColor = RGBCOLOR(0x69BA45);
        _logoutBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        _logoutBtn.titleLabel.textColor = [UIColor whiteColor];
        _logoutBtn.layer.cornerRadius = 5;
        [_logoutBtn setTitle:@"退出登录" forState:UIControlStateNormal];
        [_logoutBtn addTarget:self action:@selector(onClickLogout) forControlEvents:UIControlEventTouchUpInside];
    }
    return _logoutBtn;
}



@end
